using System;
using System.Collections.Generic;
using System.Text;

using EnvDTE;
using EnvDTE80;
using VsWebSite;

namespace Microsoft.Practices.RepositoryFactory.CommonHelpers
{
    public class ProjectFolderFinder
    {
        private DTE _dte;
        private Project _parentProject;
        

        /// <summary>
        /// Create finder object.
        /// </summary>
        /// <param name="dte">The VS environment to search for projects.</param>
        public ProjectFolderFinder(DTE dte, Project parentProject)
        {
            _dte = dte;
            _parentProject = parentProject;
        }

        private List<ProjectItem> GetAllFolders(ProjectItems folderList)
        {

            List<ProjectItem> projectFolders = new List<ProjectItem>();

            foreach (ProjectItem projectItem in folderList)
            {
                if (projectItem.Kind == Constants.vsProjectItemKindPhysicalFolder)
                {
                    projectFolders.Add(projectItem);
                    if (projectItem.ProjectItems != null)
                    {
                        projectFolders.AddRange(GetAllFolders(projectItem.ProjectItems));
                    }
                }
            }

            return projectFolders;
        }



        public List<ProjectItem> GetAllFolders()
        {
            return GetAllFolders(_parentProject.ProjectItems);

        }




    }
}
